﻿#ifndef __SBCONF_H__
#define __SBCONF_H__

#if _MSC_VER
#pragma once
#endif

// build prerequisite
#define SB_BUILD_ALLOC					1
#define SB_BUILD_PRINTF					1

// platform
#if defined(_WIN32)
#	define _SB_WINDOWS_					1
#	if !defined(WINAPI_FAMILY)
#		define _SB_WINDOWS_DESKTOP_		1
#	else
#		if WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP
#			define _SB_WINDOWS_DESKTOP_	1
#		elif WINAPI_FAMILY == WINAPI_FAMILY_PC_APP
#			define _SB_WINDOWS_STORE_	1
#		elif WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
#			define _SB_WINDOWS_PHONE_	1
#		endif
#	endif
#	if _SB_WINDOWS_STORE_ || _SB_WINDOWS_PHONE_
#		define _SB_WINDOWS_RT_			1
#		define _SB_WINDOWS_UNIVERSAL_	1
#	endif
#endif

#if defined(__FreeBSD__) || defined(__OpenBSD__)
#	define _SB_BSD_						1
#endif

#if defined(__linux__) || defined(__gnu_linux__)
#	define _SB_LINUX_					1
#endif

#if defined(__QNX__) || defined(__QNXNTO__)
#	define _SB_QNX_						1
#endif

#if defined(__BEOS__)
#	define _SB_BEOS_					1
#endif

#if defined(__android__) || defined(__ANDROID__)
#	define _SB_ANDROID_					1
#endif

#if defined(__APPLE__)
#	define _SB_APPLE_					1
#	if defined(__MACH__)
#		define _SB_OSX_					1
#	else
#		include "TargetConditionals.h"
#		if TARGET_OS_IPHONE
#			define _SB_IOS_				1
#		elif TARGET_OS_MAC
#			define _SB_OSX_				1
#		endif
#	endif
#endif

#if defined(__kibot__)
#	define _SB_KIBOT_					1
#endif

#if defined(__ktkb2__)
#	define _SB_KIBOT2_					1
#endif

#if defined (_XBOX) || defined(_XBOX360) || defined(_XBOXONE)
#	define _SB_XBOX_					1
#endif

#if defined(_PS3_) || defined(_PS4_)
#	define _SB_PLAYSTATION_				1
#endif

#if defined(__unix__) || defined(__unix) || _SB_OSX_
#	define _SB_UNIX_					1
#endif

#if _SB_ANDROID_ || _SB_IOS_ || _SB_WINDOWS_PHONE_
#	define _SB_MOBILE_					1
#endif

// processor
#if defined(_WIN64) || defined(__AMD64__) || defined(__X86_64__) || defined(_M_X64) || defined(_LP64)
#	define _SB_64_						1
#endif

#if defined(__X86__) || defined(_M_X86) || defined(__AMD64__) || defined(__X86_64__) || defined(__x86_64__) || defined(_M_X64) || defined(__i386__)
#	define _SB_X86_						1
#endif

#if _SB_X86_ && _SB_64_
#	define _SB_X64_						1
#endif

#if defined(__PPC__) || defined(_M_PPC) || defined(_M_CELL) || defined (_MPPC_)
#	define _SB_PPC_						1
#endif

#if defined(__MIPS__) || defined(_M_MIPS) || defined(_M_M3)
#	define _SB_MIPS_					1
#endif

#if defined(__arm__) || defined(__ARM__) || defined(_M_ARM) 
#	define _SB_ARM_						1
#	if defined(__arm_v7a__) || defined(__ARM_V7A__) || defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) || defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__) || defined(__ARM_ARCH_7S__)
#		define _SB_ARM_V7_				1
#	endif
#endif

#if !_SB_X86_ && !_SB_PPC_ && !_SB_MIPS_ && !_SB_ARM_
#	define _SB_X86_						1
#	if !_SB_X64_ && _SB_64_
#		define _SB_X64_					1
#	endif
#endif

// compiler
#if __GNUC__
// 4.1 -> 40100, 4.5 -> 40500, 4.10 -> 41000
#	define _SB_GNUC_					(__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
#endif

#if !defined(__cplusplus) || defined(CINTERFACE)
#	define _SB_C_						1
#	if defined(__STDC_VERSION__)
#		if __STDC_VERSION__ >= 199901L
#			define _SB_C99_				1
#		endif
#		if __STDC_VERSION__ >= 201112L
#			define _SB_C11_				1
#		endif
#	endif
#endif

#if defined(__cplusplus)
#	define _SB_CPP_						1
#	if __cplusplus >= 201103L || _MSC_VER >= 1700
#		define _SB_CPP11_				1
#		define _SB_CPP11_MOVE_			1
#		define _SB_CPP11_FOR_			1
#		if _MSC_VER >= 1800 || __GNUC__ >= 4
#			define _SB_CPP11_CLS_		1
#		endif
#	endif
#endif

#if defined(STATIC) || defined(_STATIC)
#	define _SB_STATIC_					1
#endif

#if defined(_DEBUG)
#	define _SB_DEBUG_					1
#endif

#if defined(_MANAGED)
#	define _SB_MANAGED_					1
#endif

#if defined(_SB_UNIX_) || defined(__PTHREAD__)
#	define _SB_PTHREAD_					1
#endif

#if defined(_WINCONV) || defined(_SB_WINDOWS_)
#	define _SB_WINCONV_					1
#endif

#define _SB_VERSION_					201405L

#ifdef _CHAR_UNSIGNED
#	error "Compiler option: char type must be signed"
#endif

#ifdef _MSC_VER
#	if defined(_ITERATOR_DEBUG_LEVEL) && _ITERATOR_DEBUG_LEVEL != 0
#		pragma message("_ITERATOR_DEBUG_LEVEL is not 0. probably do not compatible with sb.")
#	else
#		define _ITERATOR_DEBUG_LEVEL		0	// C++ STL iterator debug level
#	endif
#endif

#endif	// __SBCONF_H__
